/**
 * 
 */
package com.lgf.extdemo.action;

import java.io.IOException;
import java.util.Enumeration;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.lgf.extdemo.service.DemoDataService;
import com.lgf.extdemo.service.TreeService;

/**
 * @author rj
 *
 */
public class TreeAction extends HttpServlet{
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doPost(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		String id = request.getParameter("node");
		String type = request.getParameter("type");
		if ("getDemoTree".equals(type)) {
			DemoDataService service = new DemoDataService();
			int deep = 0;
			int resourceid = 1;
			String treeStr = service.getTreeDate(resourceid,Integer.valueOf(id),deep);
			response.getWriter().write(treeStr);
			response.getWriter().flush();
		}
		
		Enumeration enure = request.getParameterNames();
		while (enure.hasMoreElements()) {
			String paramenter = (String) enure.nextElement();
			System.out.println(paramenter + ":" + request.getParameter(paramenter));
		}
	}
}
